package com.candoit.webapps.pricing.bean.validator;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

@ManagedBean(name = "stringvalidator")
@ViewScoped
public class StringValidator implements Validator {

	public void validate(FacesContext context, UIComponent component,
			Object value) throws ValidatorException {
		String cadena = (String)value;
		if ((cadena == null || cadena.equals(""))) {
            throw new ValidatorException(new FacesMessage("Campo obligatorio"));
        }

	}

}
